FUNCTION GetMaxOfGridFloat &
!
(grid, maskReal, maskInteger) &
!
RESULT (max)
IMPLICIT NONE
!Arguments with intent(in):
TYPE (grid_real), INTENT(IN) :: grid
TYPE (grid_real), OPTIONAL, INTENT(IN) :: maskReal
TYPE (grid_integer), OPTIONAL, INTENT(IN) :: maskInteger
!Local declarations:
REAL (KIND = float) :: max
INTEGER (KIND = long) :: i, j
!---------------------------end of declarations--------------------------------
max = - HUGE (max)
!check that grid and mask have the same coordinate reference system
IF (PRESENT (maskReal)) THEN
IF ( .NOT. CRSisEqual(maskReal,grid) ) THEN
CALL Catch ('error', 'GridStatistics', &
'calculate max: ', argument = &
'coordinate reference system of mask differs from input grid' )
END IF
DO j = 1, maskReal % jdim
DO i = 1, maskReal % idim
IF (maskReal % mat(i,j) /= maskReal % nodata) THEN
IF (grid % mat(i,j) > max) THEN
max = grid % mat(i,j)
END IF
END IF
END DO
END DO
ELSE IF (PRESENT (maskInteger)) THEN
IF ( .NOT. CRSisEqual(maskInteger,grid) ) THEN
CALL Catch ('error', 'GridStatistics', &
'calculate max: ', argument = &
'coordinate reference system of mask differs from input grid' )
END IF
DO j = 1, maskInteger % jdim
DO i = 1, maskInteger % idim
IF (maskInteger % mat(i,j) /= maskInteger % nodata) THEN
IF (grid % mat(i,j) > max) THEN
max = grid % mat(i,j)
END IF
END IF
END DO
END DO
ELSE
DO j = 1, grid % jdim
DO i = 1, grid % idim
IF (grid % mat(i,j) /= grid % nodata) THEN
IF (grid % mat(i,j) > max) THEN
max = grid % mat(i,j)
END IF
END IF
END DO
END DO
END IF
RETURN
END FUNCTION GetMaxOfGridFloat